//书写品牌管理模块接口
import request from '@/utils/request'
import type { TArticleListResponseData, TArticle } from './type'
enum API {
  //获取已有品牌接口
  URL_ARTICLE_LIST = '/v1/m/article/allArticles',
  // //添加品牌
  URL_ARTICLE_ADD = '/v1/m/article',
  URL_ARTICLE_UPDATE = '/v1/m/article/',

  //删除已有品牌
  URL_ARTICLE_DELETE = '/v1/m/article/',
}

export const reqArticleList = (
  pageNum: number,
  pageSize: number,
  articleTitle: string,
  columnId: string,
) =>
  request.get<any, TArticleListResponseData>(
    API.URL_ARTICLE_LIST +
      `?page=${pageNum}&pageSize=${pageSize}&articleTitle=${articleTitle}&columnId=${columnId}`,
  )
// //添加与修改已有品牌接口方法
export const reqAddOrUpdateArticle = (data: TArticle) => {
  if (data.articleId) {
    return request.put<any, any>(API.URL_ARTICLE_UPDATE + data.articleId, data)
  } else {
    return request.post<any, any>(API.URL_ARTICLE_ADD, data)
  }
}

export const reqDeleteArticle = (id: string) =>
  request.delete<any, any>(API.URL_ARTICLE_DELETE + id)
